package com.apes.fa.report;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.frame.model.DutyCenter;
import com.apes.scm.masterdata.party.model.PartyRole;
import com.apes.scm.masterdata.product.model.FaCategory;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @Title: FaAssetDepreciation
 * @Description: 资产折旧明细表
 * @author: ZhengZeXian
 * @create: 2021/12/22 10:18
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = FaAssetDepreciation.CONST_TABLE_NAME)
public class FaAssetDepreciation extends Model {

    public static final String CONST_TABLE_NAME = "fa_asset_depreciation";

    @Id
    @Column(name = "id", nullable = false, length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "资产折旧明细表", padding = 8)
    @Comment("编号")
    private String id;

    @Column(name = "state")
    @Comment("单据状态")
    @States(name = "单据状态", values = {
            @State(id = "create", name = "创建"),
            @State(id = "done", name = "完成")
    })
    private String state;

    @Column(name = "finance_date")
    @Comment("财务日期")
    private Date financeDate;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fa_category_id", referencedColumnName = "id")
    @Comment("固定资产分类编码")
    private FaCategory faCategory;

    @Comment("公司")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id")
    private PartyRole company;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "cost_center_id", referencedColumnName = "id",nullable = false)
    @Comment("成本中心")
    private DutyCenter costCenter;

    @Column(name = "month_original_value", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("月末原值")
    private double monthOriginalValue = 0;

    @Column(name = "month_depreciation", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("月末折旧")
    private double monthDepreciation = 0;

    @Column(name = "original_value_increased", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("原值增加")
    private double originalValueIncreased = 0;

    @Column(name = "original_value_decrease", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("原值减少")
    private double originalValueDecrease = 0;

//    @Column(name = "original_value_balance", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
//    @Comment("原值余额")
//    private double originalValueBalance = 0;

    @Column(name = "increase_depreciation", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("本月增加折旧")
    private double increaseDepreciation = 0;

    @Column(name = "reduce_depreciation", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("本月减少折旧")
    private double reduceDepreciation = 0;

    @Column(name = "accumulated_depreciation", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("累计折旧")
    private double accumulatedDepreciation = 0;

}
